package com.wlhse.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.wlhse.dao.AndroidDao;
import com.wlhse.dto.outDto.AndroidDto;
import com.wlhse.service.AndroidService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AndroidServiceImpl implements AndroidService {

    @Resource
    private AndroidDao androidDao;

    @Override
    public String getAndroidDto() {
        List<AndroidDto> list = androidDao.getAndroidDto();
        AndroidDto androidDto;
        for (AndroidDto aList : list) {
            androidDto = aList;
            int planId = Integer.parseInt(androidDto.getPlanID());
            List<String> list1 = androidDao.getItme3(planId);
            StringBuilder str = new StringBuilder();
            for (String s : list1) str.append(s).append(",");
            String temp = str.substring(0, str.length() - 1);
            androidDto.setTaskCheckItemID(temp);
            androidDto.setInspectionTime(androidDto.getStartDate() + "/" + androidDto.getEndDate());
            androidDto.setEndDate(null);
            androidDto.setStartDate(null);
        }
        JSONObject object = new JSONObject();
        object.put("serverVersion", "0.0.1");
        object.put("status", 1);
        object.put("message", "成功");
        object.put("task", list);
        return object.toJSONString();
    }

}